﻿@model bugtracker.Models.BugEventList

@{
    ViewBag.Title = "Details";
}

<h2>Details</h2>

<fieldset>
    <legend>Bug #@Html.DisplayFor(model => model.Bug.ID)</legend>

    <div class="display-label">Title</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Bug.Title)
    </div>


    <div class="display-label">Description</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Bug.Description)
    </div>

    <div class="display-label">Criticality</div>
    <div class="display-field">
        @Html.Label(bugtracker.Controllers.DataController.getCriticalityTypeString(Model.Bug.Criticality))
    </div>

    <div class="display-label">Priority</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Bug.PriorityID)
    </div>

    <div class="display-label">Status</div>
    <div class="display-field">
        @Html.Label(bugtracker.Controllers.DataController.getStatusTypeString(Model.Bug.StatusID))
    </div>

    <div class="display-label">Type</div>
    <div class="display-field">
        @Html.Label(bugtracker.Controllers.DataController.getBugTypeString(Model.Bug.BugTypeID))
    </div>

    <br/>
    <hr/>
    <div id="detailviewbuttons">
        <!-- #dialog is the id of a DIV defined in the code below -->
        <a href="#dialog" onclick="showModalPopup('/Bugs/Edit/@Model.Bug.ID')">Edit</a>
        | 
        @{
          if ( ViewBag.alreadySubscribed == true ) {  
           @Html.ActionLink("UnSubscribe", "DeleteSubscription", "Subscription", 
               new { UserName = HttpContext.Current.User.Identity.Name, SubscriptionBugID = Model.Bug.ID }, null); 
          }
          else {
              @Html.ActionLink("Subscribe", "CreateNewSubscription", "Subscription", 
               new { UserName = HttpContext.Current.User.Identity.Name, SubscriptionBugID = Model.Bug.ID }, null);
          }
        }     
        
    </div>

</fieldset>

<h2>Event History</h2>

<fieldset>
<table>
    <tr>
        <th>
            Create Time
        </th>
        <th>
            User
        </th>
        <th>
            Event Type
        </th>
        <th>
            Comment
        </th>
    </tr>

@foreach (var item in Model.Events)
{
    if (Model.Bug.ID == item.BugID)
    {        
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.CreateTime)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.User)
        </td>
        <td>
            @Html.Label(bugtracker.Controllers.DataController.getLogEventTypeString(item.EventType))
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Comment)
        </td>
    </tr>
    }
}

</table>
</fieldset>